#include "stdio.h"

int gcd(int a, int b){
  int ret;
  if (a == 0 && b != 0) {
    ret = b;
  }
  if (a != 0 && b == 0) {
    ret = a;
  }
  else {
    for (int i = 1; i <= a; i++) {
      if (a % i == 0 && b % i == 0) {
        ret = i;
      }
    }
  }
  return ret;
}

int main(int argc, char const *argv[]) {
  int num_1, num_2;
  scanf("%d %d", &num_1, &num_2);
  while (!(num_1 == 0 && num_2 == 0)) {
    printf("%d\n", gcd(num_1, num_2));
    scanf("%d %d", &num_1, &num_2);
  }

  return 0;
}
